<?php

/**
 * CargoParcel filter form base class.
 *
 * @package    symfony
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseCargoParcelFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'cargo_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Cargo'), 'add_empty' => true)),
      'parcel_length'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'parcel_width'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'parcel_height'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'parcel_weight'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'parcel_property' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ParcelProperty'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'cargo_id'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Cargo'), 'column' => 'id')),
      'parcel_length'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'parcel_width'    => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'parcel_height'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'parcel_weight'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'parcel_property' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('ParcelProperty'), 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('cargo_parcel_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'CargoParcel';
  }

  public function getFields()
  {
    return array(
      'id'              => 'Number',
      'cargo_id'        => 'ForeignKey',
      'parcel_length'   => 'Number',
      'parcel_width'    => 'Number',
      'parcel_height'   => 'Number',
      'parcel_weight'   => 'Number',
      'parcel_property' => 'ForeignKey',
    );
  }
}
